#ifndef CLIENTHANDLER_H_
#define CLIENTHANDLER_H_

#include <queue>
#include <cstdlib>

#include "protocol/Message.h"
#include "protocol/MessageParser.h"
#include "../util/Configuration.h"
#include "../repository/UserProfileManager.h"
#include "../recommender/CollaborativeFilter.h"

using namespace std;

class ClientHandler {
private:
	pthread_mutex_t ch_mutex;
	queue<pair<string, string> > request_messages;
	queue<pair<string, string> > response_messages;
	UserProfileManager* userProfileManager;
	CollaborativeFilter cf;
	bool responses;

public:
	ClientHandler();
	~ClientHandler();

	Message parse_request(const string& strmessage);
	string
	parse_response(const multimap<string, string>& message);
	void push_request(const string& mac, const string& message);
	pair<string, string> pop_response();
	void proccess_requests();
	inline bool hasResponses() const {
		return responses;
	}
};

#endif /* CLIENTHANDLER_H_ */
